package sg.edu.nus.iss.vmcs.store;
/*
 * @author khaing zar maung
 */
import java.util.*;

public class NonZeroIterator implements Iterator{
	protected StoreItem[] items;
	int pos=0;
	
	public NonZeroIterator(StoreItem[] items){
		int y=0;
		this.items = new StoreItem[items.length];
		for(int i=0;i<items.length;i++){
			StoreItem item = items[i];
			int qty = item.getQuantity();
			if(qty>0){
				this.items[y++] = item;
			}
		}		
	}
	public Object next(){
		StoreItem item = items[pos++];
		return item;
	}
	public boolean hasNext(){
		if(pos >= items.length || items[pos]==null)
			return false;
		else
			return true;
	}
	public void remove(){
		throw new UnsupportedOperationException();
	}
}
